<?php 

$result = mysql_query("SELECT * FROM title");
while($row = mysql_fetch_array($result))
  {
  echo $row['mo_title'];
  echo "<br />";
  }
$part = mysql_query('SELECT mo_title, parts FROM title INNER JOIN part
ON title.id=part.title_id
WHERE title.mo_id =2');
	
	while($row = mysql_fetch_array($part))
		//echo $row['parts'] . '<br/>';
//		echo $row['mo_title'] . '<br/>';

?>
  <!-- End Top Bar -->
  <!--main-->
<section class="example" id="mainContent">		
		  <div class="row">
		 	<div class="twelve columns">
		 		<h3>Page Title (.twelve .columns)</h3>
		 	</div>
		 </div>
         <div class="row"> 
                <?php
					if(empty($_POST['title'])){?> 	
   				 <form action="" method="post">
  					<div class="eleven columns">                    	
                            <div class="row collapse">
                            <label for="title">Title</label>
                              <div class="ten mobile-three columns">                              	
                                <input id="title" name="title" type="text" placeholder="Title" />
                              </div>
                              <div class="two mobile-one columns">
                              	<button type="submit" class="postfix button expand">Go </button>                                
                              </div>
                            </div>                                        
                    </div>
                    	<label for="parts">Part No:</label>
  						<select id="parts" name="parts" class="one" style="height:32px; font-size:20px">
							<?php			
                                for($i=1;$i<301;$i++){
                                ?>
                            <option value="<?php echo $i;?>"><?php echo $i?></option>
                            <?php }?> 
                    	</select>
                        
  					
              	</form>
                    <?php }
	?>
    
    <!--step 2-->    	
						<?php
                                if(!empty($_POST['title']))
                                {
                                    $title = $_POST['title'];
                                            
                                ?>
                                <form action="check.php" method="post">   
                                <div class="row">
                                    <div  class="twelve columns"> 
                                    	<label for="title">Title:</label>  
                                   	 	<input id="title" type="text" class="twelve success" name="title" value="<?php echo $title?>" placeholder="tile" /> 
                                    </div>
                                </div>
                                <div class="row">
                                    <div  class="twelve columns">                                    	             
										<?php			
                                        for($i=0;$i<$_POST['parts'];$i++){
                                        ?>
                                        <div  class="three columns">                                        
                                            <input type="text" class="twelve" name="part[]" placeholder="Part <?php echo $i+1;?>" />                                                  
                                        </div>
										<?php }?>
                                    </div>
                                </div>
                                <input class="button" name="addnew" type="submit" value="Submit" />
                                </form>
                        <?php 
                        }	
                            ?>
		                            
    <!--end step 2-->
  		</div>
  <!--end main-->  